<template>
    <div id="nav">
        <div class="title">
            <div class="header">
                <div>仓库系统管理</div>
                <span class="top_span">{{storname}}</span>
            </div>
        </div>
        <div class="body">
            <div class="delivery" v-if="isShowck">
                <a v-on:click="check_session('ck')">
                    <img src="./../../../static/img/1.png">
                    <p>销售出库管理</p>
                    <span class="arr"></span>
                </a>
            </div>
            <div class="delivery" v-if="isShowrk">
                <a v-on:click="check_session('rk')">
                    <img src="./../../../static/img/2.png">
                    <p>采购入库管理</p>
                    <span class="arr"></span>
                </a>
            </div>
            <div class="delivery" v-if="isShowqtc">
                <a v-on:click="check_session('ll')">
                    <img src="./../../../static/img/3.png">
                    <p>领料单管理</p>
                    <span class="arr"></span>
                </a>
            </div>
            <div class="delivery" v-if="isShowqtr">
                <a v-on:click="check_session('qtr')">
                    <img src="./../../../static/img/buhuo.png">
                    <p>补货单管理</p>
                    <span class="arr"></span>
                </a>
            </div>
            <div class="delivery" v-if="isShowkhqr">
                <a v-on:click="check_session('kh')">
                    <img src="./../../../static/img/khqr.png">
                    <p>客户收货确认</p>
                    <span class="arr"></span>
                </a>
            </div>
            <div class="delivery" v-if="isShowthh">
                <a v-on:click="check_session('thh')">
                    <img src="./../../../static/img/tuihuo.png">
                    <p>退换货管理</p>
                    <span class="arr"></span>
                </a>
            </div>
            <div class="delivery" v-if="isShowqtr || isShowrk">
                <router-link to="Print">
                    <img src="./../../../static/img/打印机@2x.png">
                    <p>打印配置</p>
                    <span class="arr"></span>
                </router-link>
            </div>
        </div>
    </div>
</template>
<script>
export default {
  name: "nav",

  data() {
    return {
      isShowck: false,
      isShowqtc: false,
      isShowrk: false,
      isShowkhqr: false,
      isShowqtr: false,
      isShowthh: false, //退换货
      storname: "",
      model: []
    };
  },
  methods: {
    nav: function() {
      this.$http
        .post("api/motor/show_module", {
          authorization: localStorage.getItem("token")
        })
        .then(
          res => {
            this.model = res.data.result;
            this.storname = localStorage.getItem("storname");
            var result = this.model;
            console.log(result, "用户result");
            let show_thh_module = [];
            for (var i = 0; i < result.length; i++) {
              var code_ = result[i] + "";
              if (code_ == "pda_ck") {
                this.isShowck = true;
              }
              if (code_ == "pda_qtc") {
                this.isShowqtc = true;
              }
              if (code_ == "pda_rk") {
                this.isShowrk = true;
              }
              if (code_ == "pda_khqr") {
                this.isShowkhqr = true;
              }
              if (code_ == "pda_qtr") {
                this.isShowqtr = true;
              }
              if (code_ == "pda_gysqh") {
                //供应商取货
                show_thh_module.push("pda_gysqh");
              }
              if (code_ == "pda_thdcx") {
                //退货单查询
                show_thh_module.push("pda_thdcx");
              }
              if (code_ == "pda_thqh") {
                //销售退货单（待取回）
                show_thh_module.push("pda_thqh");
              }
              if (code_ == "pda_thqr") {
                //销售退货单（待确认）
                show_thh_module.push("pda_thqr");
              }
            }
            if (show_thh_module.length > 0) {
              this.isShowthh = true;
              sessionStorage.setItem(
                "show_thh_module",
                JSON.stringify(show_thh_module)
              );
            }
          },
          err => {
            this.$layer.alert(JSON.stringify(err));
          }
        );
    },
    check_session: function(obj) {
      this.$http.post("api/motor/check_session").then(
        res => {
          if (res.code == 101) {
            this.$layer.alert("当前用户已在其他设备登录");
            this.$router.push({ path: "/" });
            localStorage.removeItem("authorization");
            return;
          }
          sessionStorage.setItem("target_", obj);
          if (obj == "ll") {
            this.$router.push({ path: "/Material" });
          } else if (obj == "thh") {
            this.$router.push({ path: "/ReturnNav" });
          } else {
            this.$router.push({ path: "/" + "DeliveryScan" });
          }
        },
        err => {
          this.$layer.alert("未知错误");
          this.$router.push({ path: "/" });
          localStorage.removeItem("authorization");
        }
      );
    }
  },
  created: function() {
    this.nav();
    sessionStorage.removeItem("facilityId");
    sessionStorage.removeItem("picklistId");
    //清除出库
    sessionStorage.removeItem("invcode");
  }
};
</script>
<style lang="css" scoped>
.body {
  padding-top: 0.5rem;
  position: fixed;
  top: 14%;
  margin: 0 5%;
  width: 90%;
  background: #fff;
  box-shadow: 0px 3px 6px #999;
}

.arr {
  border: 0.25rem solid #ccc;
  border-width: 0.25rem 0 0 0.15rem;
  display: inline-block;
  height: 0.85rem;
  width: 0.85rem;
  -webkit-transform-origin: center center;
  -webkit-transform: rotate(135deg);
  -webkit-transition: all 0.5s ease-in 0.1s;
  transform-origin: center center;
  transform: rotate(135deg);
  transition: all 0.5s ease-in 0.1s;
}

.delivery a {
  border-bottom: 1px solid #e5e3e3;

  display: -webkit-box;
  line-height: 4rem;
  height: 4rem;
  background: #fff;
}

.delivery:last-child a {
  border-bottom: none;
  margin-bottom: 1.1rem;
}

.delivery p {
  width: 72%;
  font-size: 1.3rem;
}

.delivery img {
  margin: 0.8rem 1rem 0rem 1.5rem;
  width: 2.5rem;
}

.delivery {
  margin: 1rem 1rem 1.3rem 1rem;
}

.del {
  margin: 1rem 1rem 1rem 1rem;
}

.del a {
  display: -webkit-box;
  line-height: 4rem;
  height: 4rem;
  background: #fff;
}

.del p {
  width: 172%;
  font-size: 1.3rem;
}

.del img {
  margin: 0.8rem 1rem 0rem 1.5rem;
  width: 2.5rem;
}

.top_span {
  font-size: 15px;
}

.title {
  text-align: center;
  color: #fff;
  height: 11.7rem;
  line-height: 2.7rem;
  padding-top: 10px;
  font-size: 1.6rem;
  background: #668292;
}
</style>